﻿using Microsoft.EntityFrameworkCore;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Net;

namespace DetectApp;

public class ResultInfo : INotifyPropertyChanged
{
    private bool? _isOK;
    public string BoxId { get; set; } = string.Empty;
    public string WaferId { get; set; } = string.Empty;
    public string PosId { get; set; } = string.Empty;
    [Key]
    public string FullPath { get; set; } = string.Empty;
    public bool? IsOK { get => _isOK; set { _isOK = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsOK))); } }

    public event PropertyChangedEventHandler? PropertyChanged;
    public int Id { get; set; }
    public string SId { get; set; }
    public ObservableCollection<DefectCls> Defects { get; set; } = new();
    [NotMapped]
    public int SortId { get; set; }
}
public class ResultDb : DbContext
{
    public DbSet<ResultInfo> Results { get; set; }
    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
    {
        optionsBuilder.UseSqlite("Data Source=Products/Result.db");
    }
}